package com.rybbaby.tss.front.tssMemberAddSubtractRecord.dao.imp;

import com.rybbaby.tss.core.web.dao.imp.GenericDao;
import com.rybbaby.tss.front.tssMemberAddSubtractRecord.dao.ITssMemberAddSubtractRecordDao;
import com.rybbaby.tss.front.tssMemberAddSubtractRecord.entity.TssMemberAddSubtractRecord;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @description 会员加减课时记录表数据库操作实现
 * 
 * @author 雷春琼
 * 
 * @createDate 2017-08-09 下午11:59:34
 */
@Repository
public class TssMemberAddSubtractRecordDaoImp extends GenericDao<TssMemberAddSubtractRecord> implements ITssMemberAddSubtractRecordDao {

    @Override
    public List<Map<String, Object>> getDetailListBymemberId(String memberId, Integer type) {
        String sql="SELECT\n" +
                "\tsr.addSubtractType,\n" +
                "\tp. NAME packageName,\n" +
                "\tsr.classHourType,\n" +
                "\tsr.classHour,\n" +
                "\tts.realName realName,\n" +
                "\tsr.classTime,\n" +
                "\ttc. NAME className,\n" +
                "\tsr.remark,\n" +
                "\tsr.createTime,\n" +
                "\tcs. NAME systemName,\n" +
                "\te.userName\n" +
                "FROM\n" +
                "\ttss_member_add_subtract_record sr\n" +
                "LEFT JOIN tss_member_package mp ON mp.id = sr.memberPackageId\n" +
                "LEFT JOIN tss_package p ON p.id = mp.packageId\n" +
                "LEFT JOIN sys_admin_user ts ON ts.id = sr.adminUserId\n" +
                "LEFT JOIN tss_classes tc ON tc.id = sr.classId\n" +
                "LEFT JOIN tss_course c ON c.id = tc.courseId\n" +
                "LEFT JOIN sys_course_system cs ON cs.id = c.systemId\n" +
                "LEFT JOIN sys_admin_user e ON e.id = mp.adminUserId\n" +
                "WHERE\n" +
                "\tmp.memberId = ?\n" +
                "AND mp.type =?";
        return this.findForJdbc(sql,new Object[]{memberId,type});
    }
}
